<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>订单管理列表</title>
		<link rel="stylesheet" type="text/css" href="../img/base.css">
		<script language="javascript" src="../js/My97DatePicker/WdatePicker.js"></script>			
		<script language="javascript" src="../js/jquery.js"></script>		
	</head>
	<body leftmargin="8" topmargin="8" background='../img/allbg.gif'>
		<form action="order_list.php" id="order_list_form" method="post">
			<input name="act" value="search" type="hidden"/>
			<table width="98%" class="condition_table" border="0" style="height: 30px;line-height: 30px;" cellpadding="3" cellspacing="1" bgcolor="#ccd9b9" align="center">	
				<tr>
					<td height="28"  background='../img/tbg.gif'>
						<table width="100%" border="0"  cellspacing="0" cellpadding="0">
							<tr>
								<td width="20">&nbsp;</td>      
								<td width=6%>接入帐号：</td>
								<td width=13%>
									<select name="api_user" id="api_user">
										<option value="">--选择接入帐号--</option>
										<{foreach from=$api_user_list item=api_user_info}>
										<option <{if $api_user_info.api_user==$api_user}>selected="selected"<{/if}> value="<{$api_user_info.api_user}>" ><{$api_user_info.api_user}></option>
										<{/foreach}>
									</select>
								</td>
								<td width=10%>火凤凰系统订单号：</td>							
								<td width=15%><input name="booking_id" value="<{$booking_id}>"/></td>
								<td width=6%>订票日期：</td>
								<td width=38% colspan="3"><input type="text" size="10" id="order_begin_date" name="order_begin_date" value="<{$s_date}>" onClick="WdatePicker()" /> - <input type="text" id="order_end_date"  size="10" name="order_end_date" value="<{$e_date}>" onClick="WdatePicker()" /><span style="color:red; ">&nbsp;（注意：查询起始时间是同一月份的数据）</span></td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td width="20">&nbsp;</td>							
								<td width=7%>嘉禾用户名：</td>
								<td>
									<input name="web_user_name" value="<{$web_user_name}>"/>									
								</td>
								<td width=6%>临时订单号：</td>
								<td width=15%><input name="order_no" value="<{$order_no}>" /></td>
								<td width=6%>手机号：</td>
								<td ><input name="phone_no" value="<{$phone_no}>"/></td> 
								<td width=6%>订单状态：</td>							
								<td width=15%>
									<select name="result_no" >
										<option >--订单状态--</option>	
										<option <{if 10 == $result_no}>selected="selected"<{/if}> value="10">已成功</option>			
										<option <{if 100 == $result_no}>selected="selected"<{/if}> value="100">已取消</option>			
										<option <{if 99 == $result_no}>selected="selected"<{/if}> value="99">有错误</option>
									</select>								
								</td>
								</tr>    
							<tr>
								<td colspan="9" align="center" >&nbsp;&nbsp;<input type="button" value="搜索" id="submit_button" /></td>							                                      
							</tr>    
						</table>
					</td>
				</tr>	       
			</table>  
		</form>
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr bgcolor="#FFFFFF">
				<td height="4"></td>
			</tr>
		</table>	

        <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" align="center">
            <tr>
				<td align='center' valign='top'>                

                    <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA">
                        <tr bgcolor="#E7E7E7">
                            <td height="24" colspan="18" background="../img/tbg.gif">
                                §订单管理 &gt; 订单列表&nbsp;
                            </td>
                        </tr>
                        <tr align="center" bgcolor="#FAFAF1" height="22">                            
                            <td width="5%">接入帐号</td>                           
                            <td width="10%">订票日期</td>                          
                            <td width="12%">嘉禾用户名</td>
							<td width="8%">临时订单号</td>
							<td width="8%">火凤凰系统订单号</td>
							<td width="10%">上映时间</td>								
							<td width="6%">手机号</td>
							<td width="3%">票数</td>
							<td width="5%">类型</td>		
							<td width="12%">错误信息</td>
							<td width="8%">操作</td>
                        </tr>
					
                        <{foreach item=order_info from=$order_list key=k}>
							<tr align='center' bgcolor="#FFFFFF"  onMouseMove="javascript:this.bgColor='#f4fbf4';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
								
								<td align='left'>&nbsp;&nbsp;<{$order_info.api_user}></td>								                           
								<td align='left'>&nbsp;<{$order_info.add_time|date_format:'%Y-%m-%d %H:%M:%S'}></td>  
								    
								<td align='left'>&nbsp;&nbsp;<{$order_info.web_user_name}></td>      
								<td align='left'>&nbsp;&nbsp;<{$order_info.order_no}></td>    
								<td align='left'>&nbsp;&nbsp;<{$order_info.booking_id}></td>    
								<td align='left'>&nbsp;<{$order_info.show_date_time|date_format:'%Y-%m-%d %H:%M:%S'}></td>   
								
								<td align='left'>&nbsp;<{$order_info.phone_no}></td>
								
								<td align='left'>&nbsp;&nbsp;<{$order_info.ticket_count}></td>
								
								<td align='left'>&nbsp;
									<span id="id_<{$order_info.order_id}>">
										<{if $order_info.result_no == '0'}>
											已成功
										<{else if $order_info.result_no == '100' }>								
											已取消
										<{else}>
											有错误
										<{/if}>
									</span>
								</td>
								<{if $order_info.result_no == '99'}>
									<td align='left'>&nbsp;&nbsp;<{$order_info.message}></td> 
								<{else}>
									<td align='left'>&nbsp;&nbsp;</td> 
								<{/if}>								
							
								<td align='left'>&nbsp;
									<a href="order_detailed.php?order_id=<{$order_info.order_id}>&time=<{$order_info.add_time}>" target="_blank">详情</a>
									|
									<span id="op_box_<{$order_info.order_id}>">
									<{if $order_info.result_no == '0'}>
											<a href=javascript:exchange_cancle_order(<{$order_info.add_time}>,<{$order_info.order_id}>)>设置取消</a>
									<{else if $order_info.result_no == '100' }>
											<a href=javascript:exchange_success_order(<{$order_info.add_time}>,<{$order_info.order_id}>)>设置成功</a>
									<{else}>
										错误<{$order_info.result_no}>
									<{/if}>		
									</span>
									
								</td>
							</tr>
                        <{/foreach}> 
					
                        <tr bgcolor="#FAFAF1">
                            <td height="24" colspan="18">&nbsp;&nbsp;<{$page_str}></td>
                        </tr>
                    </table>                   
                </td>
            </tr>
		</table>
	</body>
</html>
<script type="text/javascript">
	
	//取消订单
	function exchange_cancle_order(time, order_id)
	{
		if(window.confirm('确定设置取消吗？\n\n确定->设置取消\n\n取消->不设置取消'))		
	    {
			$.post(
			"order_act.php", 
			{act:'change_cancle',order_id:order_id,time:time}, 
			function(call_back){
				if(call_back != 0 )
				{
					var arr = call_back.split(',');		
					var str = "<a href=javascript:exchange_success_order("+call_back+")>设置成功</a>";				
					$("#op_box_"+arr[1]).empty().append(str);
					$("#id_"+arr[1]).empty().append('设置取消');
				}
				else
				{
					alert('设置取消失败！')
				}
			},
			'json')
		}
	}
	
	//确定成功
	function exchange_success_order(time, order_id) 
	{		
		if(window.confirm('确定设置成功吗？\n\n确定->设置成功\n\n取消->不设置成功'))		
		{
			$.post(
				"order_act.php", 
				{act:'change_success',order_id:order_id,time:time}, 
				function(call_back){
					if(call_back != 0 )
					{										
						var arr = call_back.split(',');
						var str = "<a href=javascript:exchange_cancle_order("+call_back+")>设置取消</a>";					
						$("#op_box_"+arr[1]).empty().append(str);
						$("#id_"+arr[1]).empty().append('设置成功');
					}
					else
					{
						alert('确定设置失败！')
					}
				},
			'json')
		 } 	
	}
	
	$(function(){
		$("#submit_button").click(function(){		
			var begin_date = $("#order_begin_date").val();
			var end_date = $("#order_end_date").val();
			if(begin_date == '' || end_date== '')
			{
				alert("请选择订票的起始日期！")
				return false;
			}
			else
			{			   			
				if(!compare_year_month(begin_date , end_date))
				{
						alert("请选择起始订票日期为同一月份的日期！")
						return false;
				}
				else if(!compare_date(begin_date , end_date))
				{
					alert("请正确选择订票的起始日期！")
					return false;
				}
				var date=begin_date.split("-");
				var date_ym = date[0] + date[1];			
				$.post(
					"order_act.php", 
					{ym:date_ym,act:'check_class'}, 
					function(callback)
					{				
						if(callback == 1)
						{
							alert('抱歉,暂时没有该月的数据报表！');
							return false;
						}
						else
						{   
							$("#order_list_form").submit();
						}
					}, 
					'json')
			}						
			
		})
	})
	
//比较日期
function compare_date(begin_date,end_date) {
   var arr=begin_date.split("-");  
   var starttime=new Date(arr[0],arr[1],arr[2]);
   var starttimes=starttime.getTime();     
   var arrs=end_date.split("-"); 
   var endtime=new Date(arrs[0],arrs[1],arrs[2]);
   var endtimes=endtime.getTime();  
   if(starttimes > endtimes)
   {
     return false;
   } 
   else{ 
    return true; 
   }
}

//比较年月
function compare_year_month(begin_date,end_date){
   var arr=begin_date.split("-");  
   var starttime=new Date(arr[0],arr[1]);
   var starttimes=starttime.getTime();     
   var arrs=end_date.split("-"); 
   var endtime=new Date(arrs[0],arrs[1]);
   var endtimes=endtime.getTime();
   if(starttimes != endtimes)
   {
     return false;
   } 
   else{ 
    return true; 
   }
}
</script>